package com.st.base;

import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data;

@Data
@Tag(name="返回类型")
public class BaseResult<T> {
    @Schema(description = "返回标识")
    private int code;
    @Schema(description = "错误提示")
    private String msg;
    @Schema(description = "数据")
    private T data;

    /*
    返回正确信息的构造器
     */
    public static BaseResult ok(Object data){
        BaseResult r = new BaseResult<>();
        r.setCode(100);
        r.setMsg("success");
        r.setData(data);
        return r;
    }

    /*
    返回错误信息的构造器
     */
    public static BaseResult error(String msg){
        BaseResult r = new BaseResult<>();
        r.setCode(500);
        r.setMsg(msg);
        return r;
    }

}
/*为了提交*/